package com.yonyougov.devops.cruxcisupport.deployhistory;

import com.yonyougov.devops.cruxcisupport.deployhistory.dto.DeployHisPageLikeDto;
import com.yonyougov.devops.cruxcisupport.deployhistory.vo.DeployHisPageLikeVo;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * 历史模块->部署历史
 */
@Repository
public class DeployHisDaoImpl extends BaseDaoImpl<DeployHisEntity, BigInteger> implements DeployHisDao {
    private final SqlSessionTemplate sqlSessionTemplate;

    public DeployHisDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    //<!--用户自定义代码开始-->
    /**
     * 查询部署历史
     * 条件: 环境id, 环境名称, 应用id, 应用名称
     *
     * @param deployHisPageLikeDto [com.yonyougov.devops.cruxcisupport.deployhistory.dto.DeployHisPageLikeDto]
     * @return [java.util.List: com.yonyougov.devops.cruxcisupport.deployhistory.vo.DeployHisPageLikeVo]
     */
    @Override
    public List<DeployHisPageLikeVo> findPageBy(DeployHisPageLikeDto deployHisPageLikeDto) {
        String statement = DeployHisEntity.class.getName() + "Mapper.findDeployHisPageLike";
        return sqlSessionTemplate.selectList(statement, deployHisPageLikeDto);
    }

    /**
     * 查询部署历史
     * 条件: 环境id, 环境名称, 应用id, 应用名称
     *
     * @param deployHisPageLikeDto [com.yonyougov.devops.cruxcisupport.deployhistory.dto.DeployHisPageLikeDto]
     * @return [int]
     */
    @Override
    public int countBy(DeployHisPageLikeDto deployHisPageLikeDto) {
        String statement = DeployHisEntity.class.getName() + "Mapper.countDeployHisPageLike";
        return sqlSessionTemplate.selectOne(statement, deployHisPageLikeDto);
    }
    //<!--用户自定义代码结束-->
}
